package org.travel_system.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.travel_system.pojo.Evaluation;


import java.util.List;

@Mapper
public interface EvaluationMapper {
    //查询评价列表
    @Select("select * from complaint_evaluation where tourist_id=#{userId}")
    List<Evaluation> getEvaluations(Integer userId);

    //根据id查询
    @Select("select * from complaint_evaluation where evaluation_id=#{id}")
    Evaluation getEvaluationById(int id);

    //添加评价
    @Insert("insert into complaint_evaluation(tourist_id, complaint_id, evaluation_content, result_rate)" +
            "values (#{touristId},#{complaintId},#{evaluationContent},#{resultRate})")
    int addEvaluation(Evaluation evaluation);

    //删除评价
    @Delete("delete from complaint_evaluation where evaluation_id=#{id}")
    int deleteEvaluationById(int id);
}
